For the rest of this section, when you see <project>, replace it with JpaTutorial3
Create Java Project
Next we need to create a Java project. We'll keep the source separate from the bin directory:
Pull down the File menu and select New:Project
Select Java Project and click on Next
Enter a project name: <project>, again read this to know why I did not use a space in the project name.
Make sure "Create new project in workspace" is selected.
Make sure the JRE selected is 1.5.x or higher. If such a JRE does not show in the list, you can add it through Window->Preferences->JAVA->Installed JRE's.
Select Create separate source and output folders
Click Finish
Create folders and packages
Expand your <project> folder
Select the src directory
Right-click, select new:Folder
Use the name META-INF
Make sure <project> is still selected, right-click and select New:Source Folder
Enter test and click OK
Add Required Libraries
We now need to add two libraries. Note that these steps assume you've already worked through the first tutorial and are working in the same workspace. If you, you'll need to create user libraries. Review Creating User Libraries.
Edit the project properties. Select your <project> and either press alt-enter or right-click and select properties.
Select Java Build Path
Click on the Libraries tab
Click on Add Library
Select User Libraries and click Next
Select JPA_JSE by click on the check box
Click OK
Click on Add Library again
Click on JUnit
Click Next
In the pull-down list, select JUnit 4
Click Finish
Click OK
If you'd like some background information on JUnit, please go here.
Configure Persistence Unit
We now need to create the Persistent Unit definition. We are going to create a file called persistence.xml in the src/META-INF directory with the following contents:
Find the src/META-INF directory (if one does not exist, right-click, select New:Folder, enter META-INF and press enter)
Right click the src/META-INF, select new:File.
Enter persistence.xml for the name and press "OK" (Note: all lowercase. It won't make a difference on Windows XP but it will on Unix.)
Copy the contents (above) into the file and save it
Update persistence.xml
Update Persistence Unit Name
The name of the persistence unit in your just-copied persistence.xml is examplePersistenceUnit in this example we use lis for Library Information System. Make the following change:
Create Java Project
Next we need to create a Java project. We'll keep the source separate from the bin directory:Create folders and packages
Add Required Libraries
We now need to add two libraries. Note that these steps assume you've already worked through the first tutorial and are working in the same workspace. If you, you'll need to create user libraries. Review Creating User Libraries.If you'd like some background information on JUnit, please go here.
Configure Persistence Unit
We now need to create the Persistent Unit definition. We are going to create a file called persistence.xml in the src/META-INF directory with the following contents:persistence.xml
The Steps
Update persistence.xml
Update Persistence Unit NameThe name of the persistence unit in your just-copied persistence.xml is examplePersistenceUnit in this example we use lis for Library Information System. Make the following change:
Your project is now set up.